﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using UcAsp.Models;
namespace UcAsp.Controllers
{
    public class JobsController : Controller
    {
        //
        // GET: /Jobs/
        private UcAspNetEntities entities = new UcAspNetEntities();
        public ActionResult Index()
        {
            var query = from c in entities.Articless
                        where c.CategorieID == 47&&c.IsRelease==true                        
                        orderby c.IsRecommend,c.Rate,c.ID descending
                        select c;
            int pagesize = 10;
            int pageindex = 1;
            if (Request.QueryString["page"] != null)
            {
                pageindex = int.Parse(Request.QueryString["page"].ToString()) - 1;
            }
            ViewData["PageIndex"] = pageindex + 1;
            ViewData["PageCount"] = (query.Count() + 9) / 10;
            List<Articles> list = new List<Articles>();
            list = query.Skip(pageindex * pagesize).ToList<Articles>().Take(pagesize).ToList();

            return View(list);
        }

    }
}
